package com.crm.global.result;

import com.crm.global.exception.ExceptionEnum;
import lombok.Data;
import lombok.RequiredArgsConstructor;

import java.io.Serializable;
import java.time.LocalDateTime;
import java.time.ZoneOffset;

@Data
public class Message<T> implements Serializable {
    private Integer code;
    private String message;
    private Long time;
    private T data;

    public Message(ExceptionEnum enums, T data) {
        this.code = enums.getCode();
        this.message = enums.getMsg();
        this.time = LocalDateTime.now().toInstant(ZoneOffset.of("+8")).toEpochMilli();
        this.data = data;
    }

    public Message(ExceptionEnum enums) {
        this(enums,null);
    }
}
